<?php include( "templates/include/header.php" ); ?>

<script type="text/javascript">

var opened_result = null;

function OpenResult(item, id){	
	if(opened_result != null){
		$(opened_result).removeClass("ResultSelected");
		$(opened_result).removeClass("ResultLink_Hover");
	}
		
	$.ajax({
		type: "POST",
		url: "results_ajax.php",
		data: "id=" + id,
		success: function(res){
			$("#ResultLayer").html(res);
			opened_result = item;
			$(opened_result).addClass("ResultSelected");
		},
		error:function(){
			alert('Erreur inconnue !');
			opened_result = null;
		}
	});
}


$(function(){
	$(".ResultLink").mouseover(function(){
		if(opened_result == this)return;
		$(this).addClass("ResultLink_Hover");
	});
	$(".ResultLink").mouseout(function(){
		if(opened_result == this)return;
		$(this).removeClass("ResultLink_Hover");
	});
});

</script>

    <div align="left" style="height:600px;padding:0;margin:0">
      <div id="ResultCategory">
        <ul>
          <?php
            foreach ( $results['results'] as $season ) {
          ?>
				    <li>
					    <div style="cursor:pointer" onclick="$('#res_0').toggle();"><?php echo $season->title ?></div>
					    <ul id="res_0" style="display:none">
                <?php
                  $data = Event::getBySeason( $season->id );
                
                  foreach ( $data['results'] as $event ) {
    			  			  echo( '<li class="ResultLink" style="cursor:pointer" onclick="OpenResult(this, ' . $event->id . ');" >' . $event->title . '</li>' );
                  }?>
              </ul>
            </li>
        <?php
          }
        ?>
        </ul>
			</div>
			&nbsp;
			<div id="ResultLayer"></div>
	  </div>

</center>

					<br />

<?php include( "templates/include/footer.php"); ?>
